/*
 *  $Id: Dispell.cs 1189 2010-11-12 14:40:06Z thenn.erannor $
 *  This file is a part of Ragima CCG.
 *  (C) 2008 Ragima development group.
 *
 *  Licensed under the terms of the GNU GPL License version 2.
 *
 */

using Ragima.Helper;

namespace Ragima.Cards001.Air.Spells {
    public class Dispell : SpellCard<Affect> {
        public Dispell() : base("001_a_s_dispell") {
            Level = CompleteLevel.ReadyForTest;
            Element = ElementType.Air;
            Value = 100;
            Target = EnchantmentTarget.OnlyDispellable;
            AddManaCost(ElementType.Air, 1);
        }

        protected override void DoAction(TargetArgs<Affect> args) {
            bool isLand = args.Target.Owner is Land;
            if (!isLand) {
                Region region = args.Target.Owner.FindRegion();

                UI.ParticleInfo info = new UI.ParticleInfo(Data.Particles.Shine01);
                info.AddPhase(20, 20, 0xffffff.ToColor(), 0.5, 0.3, 0, UI.ParticleTrajectory.Line(-90, 0.2));
                UI.ParticleEmitterInfo emitter = new UI.ParticleEmitterInfo();
                emitter.Duration = 25;
                emitter.Rate = UI.ParticleRate.Always(80);
                emitter.Generator = UI.ParticleGenerator.Same(info, UI.ParticlePoints.TraceBorder(region.Rect));
                Application.CurrentScene.AddEmitter(emitter.Create());
            }
            args.Target.Dispell();
        }
    }
}
